package com.qf.hospital.mapper;

import com.qf.hospital.entity.SysMenu;
import com.qf.hospital.entity.SysUser;
import com.qf.hospital.entity.SysUserExample;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface SysUserMapper {
    long countByExample(SysUserExample example);

    int deleteByExample(SysUserExample example);

    int deleteByPrimaryKey(Integer userId);

    int insert(SysUser record);

    int insertSelective(SysUser record);

    List<SysUser> selectByExample(SysUserExample example);

    SysUser selectByPrimaryKey(Integer userId);

    int updateByExampleSelective(@Param("record") SysUser record, @Param("example") SysUserExample example);

    int updateByExample(@Param("record") SysUser record, @Param("example") SysUserExample example);

    int updateByPrimaryKeySelective(SysUser record);

    int updateByPrimaryKey(SysUser record);

    List<SysMenu> selectMenuByUserId(@Param("userId") Integer userId);

    @Select(value = "SELECT rid FROM `sys_role_user` WHERE uid = #{userId}")
    List<Integer> findRoleByUserId(@Param("userId") Integer userId);

    @Delete(value = "delete FROM `sys_role_user` WHERE uid = #{userId}")
    void deleteUserRoleByUserId(@Param("userId") Integer userId);

    int addUserRoles(@Param("userId") Integer userId, @Param("ids") Integer[] ids);
}